package com.lm.auth.handler;

import com.lm.common.security.handler.AbstractAuthenticationFailureEventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;

/**
 * 登录失败处理类
 *
 * @author lm
 * @date 2019/8/26 10:21
 */
@Component
public class ScmAuthenticationFailureHandler extends AbstractAuthenticationFailureEventHandler {

    private static final Logger logger = LoggerFactory.getLogger(ScmAuthenticationFailureHandler.class);

    /**
     * 登录失败
     *
     * @param authentication
     * @param authenticationException
     */
    @Override
    public void handle(Authentication authentication, AuthenticationException authenticationException) {
        logger.info("用户：{} 登录失败，异常：{}", authentication.getPrincipal(), authenticationException.getLocalizedMessage());
    }

}
